<?php

/**
 * JingYao-backend
 *
 * @link     https://gitee.com/wang-zhihui-release/jingyao-backend
 * @apiDocument https://gitee.com/wang-zhihui-release/jingyao-backend/wikis/
 */

namespace App\Http\Requests;

use App\Enums\AreaEnum;
use App\Enums\EducationEnum;
use App\Enums\HasOrNotEnum;
use App\Enums\MaritalStatusEnum;
use App\Enums\UserSexEnum;
use App\Rules\CheckEnum;
use App\Rules\CheckNowAddressRule;

class SetUserProfileRequest extends CommonRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'sex' => [new CheckEnum(new UserSexEnum())],
            'phone' => 'size:11',
            'birthday' => 'date',
            'marital_status' => [new CheckEnum(new MaritalStatusEnum())],
            'has_children' => [new CheckEnum(new HasOrNotEnum())],
            'education' => [new CheckEnum(new EducationEnum())],
            'come_beijing_time' => 'date',
            'industry' => ['required'],
            'has_contribution' => [new CheckEnum(new HasOrNotEnum())],
            'has_violated' => [new CheckEnum(new HasOrNotEnum())],
            'name' => 'required',
            'user_id' => 'required',
            'now_address' => ['required', new CheckNowAddressRule()],
            'id_card_number' => 'required',
            'area' => ['required', new CheckEnum(new AreaEnum())],
        ];
    }

    public function messages()
    {
        return [
            'phone.size' => '手机号码长度不正确',
        ];
    }
}
